package com.cy.comstore.controller;

import com.cy.comstore.entity.District;
import com.cy.comstore.service.IDistrictService;
import com.cy.comstore.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("districts")
public class DistrictController extends BaseController{
    @Autowired
    private IDistrictService districtService;

    //凡是以district开头的都映射到该方法，无论后边跟不跟斜杆
    @GetMapping({"/",""})
    public JsonResult<List<District>> getByParent(String parent){
        List<District> list = districtService.getByParent(parent);
        return new JsonResult<>(OK,list);
    }
}
